/*
package com.xiaoxu.intranetweb.mybatisplusSzappdb.business.truck;

import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.business.log.SysLogBu;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.dao.UserInfoDao;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.entity.CTrucks;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.entity.SysUser;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.service.ICTrucksService;
import com.xiaoxu.intranetweb.util.SzResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class IdentifyBu {
    @Autowired
    private ICTrucksService icTrucksService;
    @Autowired
    private SysLogBu sysLogBu;
    @Autowired
    UserInfoDao userInfoDao;

    //是否识别排队
    public SzResult identify(String id, Integer isOrNot, String token) throws Exception {
        QueryWrapper<CTrucks> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("TRUCKS_ID", id);
        queryWrapper.eq("TRUCKS_DELETED", 0);
        CTrucks cTrucks = icTrucksService.getOne(queryWrapper);
        SysUser user = userInfoDao.getUser(StpUtil.getLoginIdByToken(token).toString());
        if (isOrNot == 1) {
            cTrucks.setTrucksIdentyQueue(1);
            icTrucksService.updateById(cTrucks);
            String trucksTruckno = cTrucks.getTrucksTruckno();
            sysLogBu.logRecord("必须识别排队", user.getTrueName(), "添加了车牌号为" + trucksTruckno + "的车辆必须识别排队的信息");
        } else {
            cTrucks.setTrucksIdentyQueue(0);
            icTrucksService.updateById(cTrucks);
            String trucksTruckno = cTrucks.getTrucksTruckno();
            sysLogBu.logRecord("取消必须识别排队", user.getTrueName(), "取消了车牌号为" + trucksTruckno + "的车辆必须识别排队的信息");
        }
        return SzResult.Success();
    }


    //是否识别装车
    public SzResult identifyLoad(String id, Integer isOrNot, String token) throws Exception {
        QueryWrapper<CTrucks> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("TRUCKS_ID", id);
        queryWrapper.eq("TRUCKS_DELETED", 0);
        CTrucks cTrucks = icTrucksService.getOne(queryWrapper);
        SysUser user = userInfoDao.getUser(StpUtil.getLoginIdByToken(token).toString());
        if (isOrNot == 1) {
            cTrucks.setTrucksIdentyLoad(1);
            icTrucksService.updateById(cTrucks);
            String trucksTruckno = cTrucks.getTrucksTruckno();
            sysLogBu.logRecord("必须识别装车", user.getTrueName(), "添加了车牌号为" + trucksTruckno + "的车辆必须识别装车的信息");
        } else {
            cTrucks.setTrucksIdentyLoad(0);
            icTrucksService.updateById(cTrucks);
            String trucksTruckno = cTrucks.getTrucksTruckno();
            sysLogBu.logRecord("取消必须识别装车", user.getTrueName(), "取消了车牌号为" + trucksTruckno + "的车辆必须识别装车的信息");
        }
        return SzResult.Success();
    }


    //车辆登记信息是否批准
    public SzResult approve(String id, Integer isOrNot, String token) throws Exception {
        QueryWrapper<CTrucks> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("TRUCKS_ID", id);
        queryWrapper.eq("TRUCKS_DELETED", 0);
        CTrucks cTrucks = icTrucksService.getOne(queryWrapper);
        SysUser user = userInfoDao.getUser(StpUtil.getLoginIdByToken(token).toString());
        if (isOrNot == 1) {
            cTrucks.setTrucksInfoApproved(1);
            icTrucksService.updateById(cTrucks);
            String trucksTruckno = cTrucks.getTrucksTruckno();
            sysLogBu.logRecord("车辆登记信息批准", user.getTrueName(), "添加了车牌号为" + trucksTruckno + "的车辆登记信息批准的信息");
        } else {
            cTrucks.setTrucksInfoApproved(0);
            icTrucksService.updateById(cTrucks);
            String trucksTruckno = cTrucks.getTrucksTruckno();
            sysLogBu.logRecord("取消车辆登记信息批准", user.getTrueName(), "取消了车牌号为" + trucksTruckno + "的车辆登记信息批准的信息");
        }
        return SzResult.Success();
    }


    //车辆是否必须排队
    public SzResult approveQueue(String id, Integer isOrNot, String token) throws Exception {
        QueryWrapper<CTrucks> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("TRUCKS_ID", id);
        queryWrapper.eq("TRUCKS_DELETED", 0);
        CTrucks cTrucks = icTrucksService.getOne(queryWrapper);
        SysUser user = userInfoDao.getUser(StpUtil.getLoginIdByToken(token).toString());
        if (isOrNot == 1) {
            cTrucks.setTrucksMustQueue(1);
            icTrucksService.updateById(cTrucks);
            String trucksTruckno = cTrucks.getTrucksTruckno();
            sysLogBu.logRecord("车辆必须排队", user.getTrueName(), "车牌号为" + trucksTruckno + "的车辆必须排队");
        } else {
            cTrucks.setTrucksMustQueue(0);
            icTrucksService.updateById(cTrucks);
            String trucksTruckno = cTrucks.getTrucksTruckno();
            sysLogBu.logRecord("取消车辆必须排队", user.getTrueName(), "取消了车牌号为" + trucksTruckno + "的车辆必须排队");
        }
        return SzResult.Success();
    }


    //刷卡进门后，是否允许有几分钟的延时时间过磅  0不允许 1允许
    public SzResult delayTime(String id, Integer isOrNot, String token) throws Exception {
        QueryWrapper<CTrucks> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("TRUCKS_ID", id);
        queryWrapper.eq("TRUCKS_DELETED", 0);
        CTrucks cTrucks = icTrucksService.getOne(queryWrapper);
        SysUser user = userInfoDao.getUser(StpUtil.getLoginIdByToken(token).toString());
        if (isOrNot == 1) {
            cTrucks.setTrucksEntered(1);
            icTrucksService.updateById(cTrucks);
            String trucksTruckno = cTrucks.getTrucksTruckno();
            sysLogBu.logRecord("刷卡进门后，是否允许有几分钟的延时时间过磅", user.getTrueName(), "添加了车牌号为" + trucksTruckno + "的车辆刷卡进门后，允许有几分钟的延时时间过磅的信息");
        } else {
            cTrucks.setTrucksEntered(0);
            icTrucksService.updateById(cTrucks);
            String trucksTruckno = cTrucks.getTrucksTruckno();
            sysLogBu.logRecord("取消刷卡进门后，是否允许有几分钟的延时时间过磅", user.getTrueName(), "取消了车牌号为" + trucksTruckno + "的车辆刷卡进门后，允许有几分钟的延时时间过磅的信息");
        }
        return SzResult.Success();
    }
}
*/
